﻿using System.Configuration;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF.Config
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        public MainWindow()
        {
            InitializeComponent();

            cb_Theme.ItemsSource = new string[2] { "Light", "Dark" };
            cb_Language.ItemsSource = new string[2] { "English", "Chinese" };

            if(appConfig.GetSection("settings") == null)
            {
                appConfig.Sections.Add("settings", new AppSettings());
            }

            this.DataContext = appConfig.GetSection("settings");
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            appConfig.Save();
        }
    }
}